<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>内存问题</title>
    <link rel="stylesheet" href="../../styles/normalize.css" />
  </head>
  <body>
    <div class="box">1</div>
    <script>
      const els = document.getElementsByTagName("*");

      // 例一
      for (let i = 0; i < els.length; i++) {
        els[i].addEventListener(
          "click",
          (e) => {
            /* 处理点击事件 */
          },
          false
        );
      }

      // 例二
      function processEvent(e) {
        /* 处理同样的点击事件 */
      }

      for (let i = 0; i < els.length; i++) {
        els[i].addEventListener("click", processEvent, false);
      }
    </script>
  </body>
</html>
